package io.wdb.wx.activity.logic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import io.wdb.modules.activity.wx.dao.MarketPrizeDao;
import io.wdb.modules.activity.wx.entity.MarketPrizeEntity;

/**
 * 
 * @ClassName: PrizeLogic.java
 * @Description:抽奖逻辑实现类
 * @Time 2017年11月23日
 * @author: Tom
 */
@Component
public class PrizeLogic {
	
	@Resource(name="marketPrizeDao")
	private MarketPrizeDao marketPrizeDao;
	
	private static List<MarketPrizeEntity> entitys = new ArrayList<MarketPrizeEntity>();
	
	private static Map<Integer,String> locationAngle = new HashMap<Integer,String>();
	static {
		
		locationAngle.put(1, "337.5");
		locationAngle.put(2, "292.5");
		locationAngle.put(3, "247.5");
		locationAngle.put(4, "202.5");
		locationAngle.put(5, "157.5");
		locationAngle.put(6, "112.5");
		locationAngle.put(7, "67.5");
		locationAngle.put(8, "22.5");
		
	}
	public MarketPrizeEntity getPrize() {
		int i = 0;
		MarketPrizeEntity marketPrizeEntity = null;
		while(i==0||marketPrizeEntity==null) {
			i = new Random().nextInt(9);
			marketPrizeEntity = marketPrizeDao.getAssignPrize(i);
		}
		return marketPrizeEntity;
	}
	public String getAngle(Integer location) {
		return locationAngle.get(location);
	}
}
